#include "Arduino.h"
#include "config.h"
//声音部分暂时不能用
int *l = new int[10];
int lp=0;

void soundbegin() {
  pinMode(soundPin, INPUT);
}

int soundReadValue() {
    int t=analogRead(soundPin);
    l[lp]=t;
    if(lp==9){
        lp=0;
    }
    else{
        lp++;
    }
  return t;
}

int soundGetLevel(){
    int maxVoice=0;
    for(int i=0;i<10;i++){
        if(l[lp]-1900>maxVoice){
            maxVoice=l[lp]-1900;
        }
    }
    if(maxVoice<100){
        return 0;
    }
    else if(maxVoice<300){
        return 1;
    }
    else if(maxVoice<600){
        return 2;
    }else{
        return 3;
    }
}